<template>
	<div class="AdminPassword" >
		<el-breadcrumb separator="/">
            <el-breadcrumb-item :to="{ path: '/' }"><i class="lh lh-sys fw_100"></i></el-breadcrumb-item>
            <el-breadcrumb-item>系统权限</el-breadcrumb-item>
            <el-breadcrumb-item>修改账号密码</el-breadcrumb-item>
        </el-breadcrumb>
		<div class="loadBox"></div>
		<div class="content_Box box-shadow mt_15 pl_10 pr_10">
			<div class="row-info clear">
				<div class='fl title-key'>账号</div>
				<div class='fl list-cont ml_5'>{{username}}</div>
			</div>
			<div class="row-info clear">
				<div class='fl title-key'><i class="lhadmin lhadmin-wujiaoxing"></i>新密码</div>
				<div class='fl list-cont'><el-input v-model="pwd1" show-password placeholder="请输入密码"></el-input></div>
			</div>
			<div class="row-info clear">
				<div class='fl title-key'><i class="lhadmin lhadmin-wujiaoxing"></i>确认新密码</div>
				<div class='fl list-cont'><el-input v-model="pwd2" show-password placeholder="请再次输入密码"></el-input></div>
			</div>
			<!-- <div class="row-info clear">
				<div class='fl title-key'><i class="zfy zfy-wujiaoxing"></i>手机号</div>
				<div class='fl list-cont'><el-input v-model="mobile" placeholder="请输入手机号"></el-input></div>
			</div> -->
			<!-- <div class="row-info clear">
				<div class='fl title-key'><i class="zfy zfy-wujiaoxing"></i>邮箱</div>
				<div class='fl list-cont'><el-input v-model="email" placeholder="请输入邮箱"></el-input></div>
			</div> -->
			<div class="clear"></div>

			<div class="submitBox">
				<span class="btnOK mr_5" @click="redactPwdSubmit">保存</span>
				<span class="resetBtn " @click="returnBtn">返回</span>
			</div>
		</div>
	</div>
</template>
<script>
	var common = require('../../static/tool.js');
	import {
		mainfun
	} from '../assets/js/main.js';
	import {
		publicData
	} from '../assets/js/data.js';
	export default {
		name: 'AdminPassword',
		data() {
			return {
				windowSizeHeight: document.documentElement.clientHeight, //浏览器可视化窗口的大小
				url: common.url,
				username: JSON.parse(sessionStorage.getItem("manageInfo")).username,
				pwd1:'',
				pwd2:'',
				mobile:'',
				email:'',
			}
		},
		mounted() {
			this.startResult();
		},
		methods: {
			startResult() {
				// this.queryUser();
			},
			// 修改密码
			redactPwdSubmit(){
				if(this.pwd1 =='' || this.pwd2 ==''){
					this.$message.error('请输入必填项！');
					return;
				}
				if(this.pwd1 !== this.pwd2){
					this.$message.error('两次密码输入不一致！');
					return;
				}
				let fn = new FormData();
				fn.append('id', JSON.parse(sessionStorage.getItem("manageInfo")).id);
				fn.append('password', this.pwd1);
				this.$http.post(this.url + '/manageUser/commonEdit',fn).then((res) => {
					if (res.data.code == '200') {
						this.$message.success('密码修改成功！');
						//定时器，一秒后退出
						setTimeout( () => {
							sessionStorage.clear();
							window.location = 'login.html';
						},1000)
					} else if (res.data.code == '8886') { //code   8886  登录过期
						sessionStorage.clear();
						this.$alert('登录已过期，请重新登录 !', '提示', {
							confirmButtonText: '确定',
							callback: action => {
								window.location = 'login.html';
							}
						});
						return;
					} else {
						this.$message.error(res.data.msg);
						return;
					}
				}, (res) => {
					this.$message.error('网络错误！');
					return;
				})
			},
			// 查询
			queryUser(){
				this.$http.post(this.url + '/zhongfy/admin/updatePassword').then((res) => {
					// console.log(res);
					if (res.data.code == '200') {
						this.username = res.data.data.username ;
						this.mobile =  res.data.data.mobile ;
						this.email =  res.data.data.email ;
					} else if (res.data.code == '8886') { //code   8886  登录过期
						sessionStorage.clear();
						this.$alert('登录已过期，请重新登录 !', '提示', {
							confirmButtonText: '确定',
							callback: action => {
								window.location = 'login.html';
							}
						});
						return;
					} else {
						this.$message.error(res.data.msg);
						return;
					}
				}, (res) => {
					this.$message.error('网络错误！');
					return;
				})
			},
			returnBtn(){  //返回上一步
				this.$router.go('-1');
			},

		},
	}
</script>

<style scoped>
	.AdminPassword {margin: 65px 15px 15px 15px;}
	.row-info{height:40px;}
	.submitBox{padding-left: 90px;margin-top: 20px;}

	/* 上传 */
</style>



// WEBPACK FOOTER //
// src/components/AdminPassword.vue